<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/11/13
 * Time: 13:35
 */

namespace app\index\controller;


use think\Db;

class Uploadfile extends Base
{
    /**
     * 文件列表
     * @return mixed
     */
    public function filesList(){
        $page = input('page')?input('page'):1;
        $list = Db::table('up_upfile')
            ->order('up_time desc')
            ->page($page, 12)
            ->select();
        $this->assign('list', $list);
        return $this->fetch('uploadfile/fileslist');
    }
    
    /**
     * 更多文件列表
     * @return \think\response\Json
     */
    public function showMore(){
        $count = Db::table('up_upfile')->count();
        return json(['status' => 200, 'count' => $count]);
    }
    
    /**
     * 更多文件列表
     * @return \think\response\Json
     */
    public function moreFiles(){
        $page = input('page');
        $type = input('type');
        $where['up_id'] = ['>',0];
        if($type){
            $where['up_type'] = $type;
        }
        $data = Db::table('up_upfile')
            ->where($where)
            ->order('up_time desc')
            ->limit(($page-1)*12, 12)
            ->select();
        return json(['status' => 200, 'data' => $data]);
    }
}